from mcp.server.fastmcp import FastMCP

from weather_02_server import WeatherInfoServer

# 初始化 MCP 服务器
mcp = FastMCP("WeatherServer")

# 初始化天气信息服务器
weather_server = WeatherInfoServer()


# 获取天气信息的工具
@mcp.tool()
async def get_weather(city: str) -> str:
    """获取指定城市的天气信息。

    参数:
    city (str): 城市名称

    返回:
    str: 天气信息描述
    """
    weather_info = await weather_server.get_city_weather(city)
    return weather_info


# 主程序
if __name__ == "__main__":
    mcp.run(transport='stdio')
